package com.freejy.ecommunity.utils;

import com.alibaba.fastjson.JSONObject;


/**
 * @author Jerry
 */
public enum ResultCode  
{

	SUCCESS(1000, "success"),

	NO_SERVICE(1010, "not open area"),
	
	FAIL(1011, "fail"),
	
	INVALID(1012, "invalid args"),
	
	UNKNOW_ERROR(1013, "unknow error"),
	
	NOT_FOUND(1014, "not found resource"),
	
	ACCOUNT_ERROR(1031, "account error"),

	EXISTS_ACCOUNT(1032, "exists account"),

	NOT_EXISTS_ACCOUNT(1033, "not exists account"),

	INVALID_ACCOUNT(1034, "invalid account"),

	NOT_VERIFIED(1035, "not verified"),
	
	SESSION_INVALID(1061, "session invalid"),
	
	TOKEN_INVALID(1062, "token invalid"),
	
	TOO_OPERATION(1201, "too operation"),

	VALIDCODE_ERROR(1202, "validcode error"),
	/**
	 *  无效的激活码
	 */
	SERIALCODE_ERROR(1203, "serialcode error"),
	
	INVALID_OPERATION(1204, "invalid operation"),
	
	REPLACE_OPERATION(1205, "replace operation"),

	FORBIDDEN(1403, "forbidden"),

	UPLOAD_MAXLIMIT_ERROR(1416, "upload too large"),

	NGWORD_ERROR(1417, "ngword error"),

	TARGET_NOT_FOUNT(1501, "target not fount"),
	
	API_ERROR(3001, "service busy");


	private int value;
	private String text;

	ResultCode(int value, String text) {
		this.value = value;

		this.text = text;
	}

	public int getValue() {
		return value;
	}

	public String getText() {
		return text;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Enum#toString()
	 */
	@Override
	public String toString()
	{
		return "{\"code\": " + value + ", \"msg\": " + text + "}";
	}
	
	public JSONObject getJson()
	{
		JSONObject json = new JSONObject();
		json.put("code", value);
		json.put("msg", text);
		return json;
	}

}
